home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / net / sun3.md / netIE.c < prev    next >
C/C++ Source or Header  |  1990-11-29  |  24KB  |  861 lines

  1. /* 
  2.  * netIE.c --
  3.  *
  4.  *    The main routines for the device driver for the Intel 82586 Ethernet 
  5.  *    Controller.
  6.  *
  7.  *      This chip has several pecularities that have to be compensated for
  8.  *      when using it.  First of all no element of the scatter-gather
  9.  *      array which is passed into the output routine can be below a
  10.  *      minimum size.  The minimum size is defined in the file netIEXmit.c
  11.  *      and is called MIN_XMIT_BUFFER_SIZE.  Secondly none of the
  12.  *      scatter-gather elements can begin on an odd boundary.  If they do,
  13.  *      the chip drops the low order bit and sends one more byte than was
  14.  *      specified.  There are warnings printed in each of these cases.
  15.  *
  16.  * TODO: Watch dogs to make sure that the chip does not get stuck.  Rumor has
  17.  *     it that because of bugs in the chip it can get stuck at any time for
  18.  *     no particular reason.
  19.  *
  20.  * Copyright 1985, 1988 Regents of the University of California
  21.  * Permission to use, copy, modify, and distribute this
  22.  * software and its documentation for any purpose and without
  23.  * fee is hereby granted, provided that the above copyright
  24.  * notice appear in all copies.  The University of California
  25.  * makes no representations about the suitability of this
  26.  * software for any purpose.  It is provided "as is" without
  27.  * express or implied warranty.
  28.  *
  29.  */
  30.  
  31. #ifndef lint
  32. static char rcsid[] = "$Header: /sprite/src/kernel/net/sun3.md/RCS/netIE.c,v 9.5 90/11/29 15:46:23 shirriff Exp $ SPRITE (Berkeley)";
  33. #endif
  34.  
  35. #include <sprite.h>
  36. #include <sys.h>
  37. #include <list.h>
  38. #include <netIEInt.h>
  39. #include <vm.h>
  40. #include <vmMach.h>
  41. #include <mach.h>
  42. #include <machMon.h>
  43. #include <assert.h>
  44.  
  45. static Net_EtherAddress BROADCAST_ADDR = {0xab,0x00,0x00,0x01,0x00,0x00};
  46.  
  47. /*
  48.  *----------------------------------------------------------------------
  49.  *
  50.  * NetIEInit --
  51.  *
  52.  *    Initialize the Intel Ethernet chip.
  53.  *
  54.  * Results:
  55.  *    SUCCESS if the Intel controller was found and initialized,
  56.  *    FAILURE otherwise.
  57.  *
  58.  * Side effects:
  59.  *    Initializes the chip.
  60.  *
  61.  *----------------------------------------------------------------------
  62.  */
  63.  
  64. ReturnStatus
  65. NetIEInit(interPtr)
  66.     Net_Interface    *interPtr;     /* Network interface. */
  67. {
  68.     Address     ctrlAddr;    /* Kernel virtual address of controller. */
  69.     int     i;
  70.     List_Links    *itemPtr;
  71.     NetIEState    *statePtr;
  72.  
  73.     DISABLE_INTR();
  74.  
  75.     /*
  76.      * Check that our structures are the correct size.  Some of the sizes
  77.      * are different on the sun4 due to padding and alignment, but that
  78.      * has been taken into account.
  79.      */
  80. #ifdef sun4
  81.     assert(sizeof(NetIESysConfPtr) == 12);
  82.     assert(sizeof(NetIERecvFrameDesc) == 28);
  83.     assert(sizeof(NetIERecvBufDesc) == 20);
  84. #else
  85.     assert(sizeof(NetIESysConfPtr) == 10);
  86.     assert(sizeof(NetIERecvFrameDesc) == 26);
  87.     assert(sizeof(NetIERecvBufDesc) == 18);
  88. #endif
  89.     assert(sizeof(NetIEIntSysConfPtr) == 8);
  90.     assert(sizeof(NetIESCBStatus) == 2);
  91.     assert(sizeof(NetIESCBCommand) == 2);
  92.     assert(sizeof(NetIESCB) == 16);
  93.     assert(sizeof(NetIECommandBlock) == 6);
  94.     assert(sizeof(NetIENOPCB) == 6);
  95.     assert(sizeof(NetIEIASetupCB) == 12);
  96.     assert(sizeof(NetIEConfigureCB) == 18);
  97.     assert(sizeof(NetIETransmitCB) == 16);
  98.     assert(sizeof(NetIETransmitBufDesc) == 8);
  99.     assert(sizeof(NetIEControlRegister) == 1);
  100.  
  101.  
  102.     ctrlAddr = interPtr->ctrlAddr;
  103.     /*
  104.      * If the address is physical (not in kernel's virtual address space)
  105.      * then we have to map it in.
  106.      */
  107.     if (interPtr->virtual == FALSE) {
  108.     ctrlAddr = (Address) VmMach_MapInDevice(ctrlAddr, 1);
  109.     }
  110.     statePtr = (NetIEState *) malloc (sizeof(NetIEState));
  111.     bzero((char *) statePtr, sizeof(NetIEState));
  112.  
  113.     statePtr->running = FALSE;
  114.  
  115.     /*
  116.      * The onboard control register is at a pre-defined kernel virtual
  117.      * address.  The virtual mapping is set up by the sun PROM monitor
  118.      * and passed to us from the netInterface table.
  119.      */
  120.  
  121.     statePtr->controlReg = 
  122.     (volatile NetIEControlRegister *) ctrlAddr;
  123.  
  124.      {
  125.     /*
  126.      * Poke the controller by resetting it.
  127.      */
  128.     char zero = 0;
  129.     ReturnStatus status;
  130.  
  131.     status = Mach_Probe(sizeof(char), &zero,
  132.         (char *)statePtr->controlReg);
  133.     if (status != SUCCESS) {
  134.         /*
  135.          * Got a bus error.
  136.          */
  137.         free((char *) statePtr);
  138.         ENABLE_INTR();
  139.         return(FAILURE);
  140.     }
  141.     }
  142.     Mach_SetHandler(interPtr->vector, Net_Intr, (ClientData) interPtr);
  143.     /*
  144.      * Initialize the transmission list.  
  145.      */
  146.  
  147.     statePtr->xmitList = &statePtr->xmitListHdr;
  148.     List_Init(statePtr->xmitList);
  149.  
  150.     statePtr->xmitFreeList = &statePtr->xmitFreeListHdr;
  151.     List_Init(statePtr->xmitFreeList);
  152.  
  153.     netIEXmitFiller = (char *)VmMach_NetMemAlloc(NET_ETHER_MIN_BYTES);
  154.     statePtr->netIEXmitTempBuffer = 
  155.         (char *)VmMach_NetMemAlloc(NET_ETHER_MAX_BYTES + 2);
  156.  
  157.     for (i = 0; i < NET_IE_NUM_XMIT_ELEMENTS; i++) {
  158.     itemPtr = (List_Links *) VmMach_NetMemAlloc(sizeof(NetXmitElement)), 
  159.     List_InitElement(itemPtr);
  160.     List_Insert(itemPtr, LIST_ATREAR(statePtr->xmitFreeList));
  161.     }
  162.  
  163.     /*
  164.      * Get ethernet address out of the rom.  It is stored in a normal order
  165.      * even though the chip is wired backwards because fortunately the chip
  166.      * stores the ethernet address backwards from how we store it.  Therefore
  167.      * two backwards makes one forwards, right?
  168.      */
  169.  
  170.     Mach_GetEtherAddress(&statePtr->etherAddress);
  171.     printf("%s Ethernet address %x:%x:%x:%x:%x:%x\n", 
  172.           interPtr->name,
  173.           statePtr->etherAddress.byte1 & 0xff,
  174.           statePtr->etherAddress.byte2 & 0xff,
  175.           statePtr->etherAddress.byte3 & 0xff,
  176.           statePtr->etherAddress.byte4 & 0xff,
  177.           statePtr->etherAddress.byte5 & 0xff,
  178.           statePtr->etherAddress.byte6 & 0xff);
  179.     /*
  180.      * Allocate space for the System Configuration Pointer.
  181.      */
  182.  
  183.     VmMach_MapIntelPage((Address) (NET_IE_SYS_CONF_PTR_ADDR));
  184.     statePtr->sysConfPtr = (NetIESysConfPtr *) NET_IE_SYS_CONF_PTR_ADDR;
  185.  
  186.     /*
  187.      * Allocate space for all of the receive buffers. The buffers are 
  188.      * allocated on an odd short word boundry so that packet data (after
  189.      * the ethernet header) will start on a long word boundry. This 
  190.      * eliminates unaligned word fetches from the RPC module which would
  191.      * cause alignment traps on SPARC processors such as the sun4.
  192.      */ 
  193.  
  194. #define    ALIGNMENT_PADDING    (sizeof(Net_EtherHdr)&0x3)
  195.     for (i = 0; i < NET_IE_NUM_RECV_BUFFERS; i++) {
  196.     statePtr->netIERecvBuffers[i] = 
  197.         VmMach_NetMemAlloc(NET_IE_RECV_BUFFER_SIZE + ALIGNMENT_PADDING)
  198.             + ALIGNMENT_PADDING;
  199.     }
  200. #undef ALIGNMENT_PADDING
  201.  
  202.     interPtr->init    = NetIEInit;
  203.     interPtr->output     = NetIEOutput;
  204.     interPtr->intr    = NetIEIntr;
  205.     interPtr->ioctl    = NetIEIOControl;
  206.     interPtr->reset     = NetIERestart;
  207.     interPtr->getStats    = NetIEGetStats;
  208.     interPtr->netType    = NET_NETWORK_ETHER;
  209.     interPtr->maxBytes    = NET_ETHER_MAX_BYTES - sizeof(Net_EtherHdr);
  210.     interPtr->minBytes    = 0;
  211.     interPtr->interfaceData = (ClientData) statePtr;
  212.     NET_ETHER_ADDR_COPY(statePtr->etherAddress, 
  213.     interPtr->netAddress[NET_PROTO_RAW].ether);
  214.     interPtr->broadcastAddress.ether = netEtherBroadcastAddress.ether;
  215.     interPtr->flags |= NET_IFLAGS_BROADCAST;
  216.     statePtr->interPtr = interPtr;
  217.  
  218.     /*
  219.      * Reset the world.
  220.      */
  221.  
  222.     NetIEReset(interPtr);
  223.  
  224.     /*
  225.      * Unmap the extra page.
  226.      */
  227.  
  228.     VmMach_UnmapIntelPage((Address) (NET_IE_SYS_CONF_PTR_ADDR));
  229.  
  230.     /*
  231.      * Now we are running.
  232.      */
  233.  
  234.     statePtr->running     = TRUE;
  235.     ENABLE_INTR();
  236.     return (SUCCESS);
  237. }
  238.  
  239.  
  240. /*
  241.  *----------------------------------------------------------------------
  242.  *
  243.  * NetIEDefaultConfig --
  244.  *
  245.  *    Set up the default configuration for the intel chip as specified
  246.  *    in the intel manual.  The only difference from the Intel manual
  247.  *    is the fifo length.
  248.  *
  249.  * Results:
  250.  *    None.
  251.  *
  252.  * Side effects:
  253.  *    The global command block is modified.
  254.  *
  255.  *----------------------------------------------------------------------
  256.  */
  257.  
  258. void
  259. NetIEDefaultConfig(statePtr)
  260.     NetIEState        *statePtr;
  261. {
  262.     NetIEConfigureCB    *confCBPtr;
  263.  
  264.     confCBPtr = (NetIEConfigureCB *) statePtr->cmdBlockPtr;
  265.     bzero((Address) confCBPtr, sizeof(NetIEConfigureCB));
  266.     NetBfShortSet(confCBPtr->cmdBlock.bits, CmdNumber, NET_IE_CONFIG);
  267.     NetBfShortSet(confCBPtr->bits, ByteCount, 12);
  268.     NetBfShortSet(confCBPtr->bits, FifoLimit, 12);
  269.     NetBfShortSet(confCBPtr->bits, Preamble, 2);
  270.     NetBfShortSet(confCBPtr->bits, AddrLen, 6);
  271.     NetBfShortSet(confCBPtr->bits, AtLoc, 0);
  272.     NetBfShortSet(confCBPtr->bits, InterFrameSpace, 96);
  273.     NetBfShortSet(confCBPtr->bits, SlotTimeHigh , 512 >> 8);
  274.     NetBfShortSet(confCBPtr->bits, MinFrameLength, 64);
  275.     NetBfShortSet(confCBPtr->bits, NumRetries, 15);
  276.  
  277. /*
  278.     confCBPtr->intLoopback = 1;
  279. */
  280.  
  281.     NetIEExecCommand((NetIECommandBlock *) confCBPtr, statePtr);
  282.     return;
  283. }
  284.  
  285.  
  286. /*
  287.  *----------------------------------------------------------------------
  288.  *
  289.  * NetIEReset --
  290.  *
  291.  *    Reset the interface.
  292.  *
  293.  * Results:
  294.  *    None.
  295.  *
  296.  * Side effects:
  297.  *    All of the pointers in the interface structure are initialized.
  298.  *
  299.  *----------------------------------------------------------------------
  300.  */
  301.  
  302. void
  303. NetIEReset(interPtr)
  304.     Net_Interface    *interPtr;     /* Interface to reset. */
  305. {
  306.     NetIEIASetupCB            *addressCommandPtr;
  307.     NetIEMASetupCB            *addressMACommandPtr;
  308.     volatile NetIECommandBlock    *diagCmdPtr;
  309.     NetIEState            *statePtr;
  310.  
  311.     /*
  312.      * Nil out all pointers.
  313.      */
  314.     statePtr = (NetIEState *) interPtr->interfaceData;
  315.     statePtr->intSysConfPtr = (NetIEIntSysConfPtr *) NIL;
  316.     statePtr->scbPtr = (NetIESCB *) NIL;
  317.     statePtr->recvFrDscHeadPtr = (NetIERecvFrameDesc *) NIL;
  318.     statePtr->recvFrDscTailPtr = (NetIERecvFrameDesc *) NIL;
  319.     statePtr->recvBufDscHeadPtr = (NetIERecvBufDesc *) NIL;
  320.     statePtr->recvBufDscTailPtr = (NetIERecvBufDesc *) NIL;
  321.  
  322.     /* 
  323.      * Reset the chip.
  324.      */
  325.  
  326.     NET_IE_CHIP_RESET(statePtr);
  327.  
  328.     /*
  329.      * Initialize memory.
  330.      */
  331.  
  332.     NetIEMemInit(statePtr);
  333.  
  334.     /*
  335.      * Allocate the system intermediate configuration pointer and the 
  336.      * system control block.
  337.      */
  338.  
  339.     statePtr->intSysConfPtr = (NetIEIntSysConfPtr *) NetIEMemAlloc(statePtr);
  340.     if (statePtr->intSysConfPtr == (NetIEIntSysConfPtr *) NIL) {
  341.     panic("Intel: No memory for the scp.\n");
  342.     }
  343.  
  344.     statePtr->scbPtr = (NetIESCB *) NetIEMemAlloc(statePtr);
  345.     if (statePtr->scbPtr == (NetIESCB *) NIL) {
  346.     panic("Intel: No memory for the scb.\n");
  347.     }
  348.  
  349.  
  350.     while (TRUE) {
  351.     /*
  352.      * Initialize the system configuration pointer.
  353.      */
  354.  
  355.     bzero((Address) statePtr->sysConfPtr, sizeof(NetIESysConfPtr));
  356.     statePtr->sysConfPtr->intSysConfPtr = 
  357.             NetIEAddrFromSUNAddr((int) statePtr->intSysConfPtr);
  358.  
  359.     /* 
  360.      * Initialize the intermediate system configuration pointer.
  361.      */
  362.  
  363.     bzero((Address) statePtr->intSysConfPtr, sizeof(NetIEIntSysConfPtr));
  364.     statePtr->intSysConfPtr->busy = 1;
  365.     statePtr->intSysConfPtr->base = 
  366.                 NetIEAddrFromSUNAddr((int) statePtr->memBase);
  367.     statePtr->intSysConfPtr->scbOffset = 
  368.                 NetIEOffsetFromSUNAddr((int) statePtr->scbPtr,
  369.                     statePtr);
  370.  
  371.     /*
  372.      * Initialize the system control block.
  373.      */
  374.  
  375.     bzero((Address) statePtr->scbPtr, sizeof(NetIESCB));
  376.  
  377.     /*
  378.      * Turn off the reset bit.
  379.      */
  380.  
  381.     NetBfByteSet(statePtr->controlReg, NoReset, 1);
  382.     MACH_DELAY(200);
  383.  
  384.     /* 
  385.      * Get the attention of the chip so that it will initialize itself.
  386.      */
  387.  
  388.     NET_IE_CHANNEL_ATTENTION(statePtr);
  389.  
  390.     /* 
  391.      * Ensure that that the chip gets the intermediate initialization
  392.      * stuff and that the scb is updated.
  393.      */
  394.     
  395.     NET_IE_DELAY(!statePtr->intSysConfPtr->busy);
  396.     NET_IE_DELAY(NetBfShortTest(statePtr->scbPtr->statusWord, 
  397.         CmdUnitNotActive, 1));
  398.  
  399.     /*
  400.      * Wait for an interrupt.
  401.      */
  402.  
  403.     NET_IE_DELAY(NetBfByteTest(statePtr->controlReg, IntrPending, 1));
  404.  
  405.     /*
  406.      * Make sure that the chip was initialized properly.
  407.      */
  408.  
  409.     if (statePtr->intSysConfPtr->busy || 
  410.         NetBfShortTest(statePtr->scbPtr->statusWord, CmdUnitNotActive, 0) ||
  411.         NetBfByteTest(statePtr->controlReg, IntrPending, 0)) {
  412.  
  413.         printf("Warning: Could not initialize Intel chip.\n");
  414.     }
  415.     if (NetBfShortTest(statePtr->scbPtr->statusWord, CmdUnitStatus, 
  416.         NET_IE_CUS_IDLE)) {
  417.         break;
  418.     }
  419.  
  420.     printf("Warning: Intel cus not idle after reset\n");
  421.     NET_IE_CHIP_RESET(statePtr);
  422.     }
  423.  
  424.     /*
  425.      * Allocate a single command block to be used by all commands.
  426.      */
  427.  
  428.     statePtr->cmdBlockPtr = (NetIECommandBlock *) NetIEMemAlloc(statePtr);
  429.     if (statePtr->cmdBlockPtr == (NetIECommandBlock *) NIL) {
  430.     panic("NetIE: No memory for the command block.\n");
  431.     }
  432.     statePtr->scbPtr->cmdListOffset =
  433.             NetIEOffsetFromSUNAddr((int) statePtr->cmdBlockPtr,
  434.                 statePtr);
  435.  
  436.     /*
  437.      * Do a diagnose command on the interface.
  438.      */
  439.  
  440.     diagCmdPtr = statePtr->cmdBlockPtr;
  441.     bzero((Address) diagCmdPtr, sizeof(*diagCmdPtr));
  442.     NetBfShortSet(diagCmdPtr->bits, CmdNumber,  NET_IE_DIAGNOSE);
  443.     NetIEExecCommand(diagCmdPtr, statePtr);
  444.     if (NetBfShortTest(diagCmdPtr->bits, CmdOK, 0)) {
  445.     panic("Intel failed diagnostics.\n");
  446.     }
  447.  
  448.     /*
  449.      * Let the interface know its address.
  450.      */
  451.  
  452.     addressCommandPtr = (NetIEIASetupCB *) statePtr->cmdBlockPtr;
  453.     bzero((Address) addressCommandPtr, sizeof(NetIEIASetupCB));
  454.     NetBfShortSet(addressCommandPtr->cmdBlock.bits, CmdNumber, NET_IE_IA_SETUP);
  455.     addressCommandPtr->etherAddress = statePtr->etherAddress;
  456.     NetIEExecCommand((NetIECommandBlock *) addressCommandPtr, statePtr);
  457.  
  458.     /*
  459.      * Set the boot multicast address.
  460.      */
  461.  
  462.     addressMACommandPtr = (NetIEMASetupCB *) statePtr->cmdBlockPtr;
  463.     bzero((Address) addressCommandPtr, sizeof(NetIEMASetupCB));
  464.     NetBfShortSet(addressCommandPtr->cmdBlock.bits, CmdNumber, NET_IE_MC_SETUP);
  465.     addressMACommandPtr->count = 1;
  466.     addressMACommandPtr->etherAddress = BROADCAST_ADDR;
  467.     NetIEExecCommand((NetIECommandBlock *) addressMACommandPtr, statePtr);
  468.  
  469.     /*
  470.      * Set up the default configuration values.
  471.      */
  472.  
  473.     NetIEDefaultConfig(statePtr);
  474.  
  475.     /*
  476.      * Set up the receive queues.
  477.      */
  478.  
  479.     NetIERecvUnitInit(statePtr);
  480.  
  481.     /*
  482.      * Enable interrupts and get out of loop back mode.  Make sure that don't
  483.      * get out of loop back mode before because the Intel is supposed to
  484.      * be unpredictable until we initialize things.
  485.      */
  486.  
  487.     NetBfByteSet(statePtr->controlReg, IntrEnable, 1);
  488.     NetBfByteSet(statePtr->controlReg, NoLoopback, 1);
  489.  
  490.     /*
  491.      * Initialize the transmit queues and start transmitting if anything ready
  492.      * to tranmit.
  493.      */
  494.  
  495.     NetIEXmitInit(statePtr);
  496.     interPtr->flags |= NET_IFLAGS_RUNNING;
  497.     return;
  498. }
  499.  
  500.  
  501. /*
  502.  *----------------------------------------------------------------------
  503.  *
  504.  * NetIERestart --
  505.  *
  506.  *    Reinitialize the Intel Ethernet chip.
  507.  *
  508.  * Results:
  509.  *    None.
  510.  *
  511.  * Side effects:
  512.  *    None.
  513.  *
  514.  *----------------------------------------------------------------------
  515.  */
  516. void
  517. NetIERestart(interPtr)
  518.     Net_Interface    *interPtr;     /* Interface to restart. */
  519. {
  520.     NetIEState    *statePtr = (NetIEState *) interPtr->interfaceData;
  521.  
  522.     DISABLE_INTR();
  523.  
  524.     /*
  525.      * Drop the current packet so the transmitting process doesn't hang.
  526.      */
  527.     NetIEXmitDrop(statePtr);
  528.  
  529.     /*
  530.      * Allocate space for the System Configuration Pointer.
  531.      */
  532.     VmMach_MapIntelPage((Address) (NET_IE_SYS_CONF_PTR_ADDR));
  533.  
  534.     /*
  535.      * Reset the world.
  536.      */
  537.     NetIEReset(interPtr);
  538.  
  539.     /*
  540.      * Unmap the extra page.
  541.      */
  542.     VmMach_UnmapIntelPage((Address) (NET_IE_SYS_CONF_PTR_ADDR));
  543.  
  544.     ENABLE_INTR();
  545.     return;
  546. }
  547.  
  548.  
  549. /*
  550.  *----------------------------------------------------------------------
  551.  *
  552.  * NetIEIntr --
  553.  *
  554.  *    Process an interrupt from the Intel chip.
  555.  *
  556.  * Results:
  557.  *    None.
  558.  *
  559.  * Side effects:
  560.  *    None.
  561.  *
  562.  *----------------------------------------------------------------------
  563.  */
  564. void
  565. NetIEIntr(interPtr, polling)
  566.     Net_Interface    *interPtr;    /* Interface to process. */
  567.     Boolean        polling;    /* TRUE if are being polled instead of
  568.                      * processing an interrupt. */
  569. {
  570.     register    NetIEState    *statePtr;
  571.     volatile register NetIESCB    *scbPtr;
  572.     register    int        status;
  573.  
  574.     statePtr = (NetIEState *) interPtr->interfaceData;
  575.     scbPtr = statePtr->scbPtr;
  576.     /*
  577.      * If we got a bus error then panic.
  578.      */
  579.     if (NetBfByteTest(statePtr->controlReg, BusError, 1)) {
  580.     printf("Warning: Intel: Bus error on chip.\n");
  581.     NetIERestart(interPtr);
  582.     return;
  583.     }
  584.  
  585.     /*
  586.      * If interrupts aren't enabled or there is no interrupt pending, then
  587.      * what are we doing here?
  588.      */
  589.     if (!(NetBfByteTest(statePtr->controlReg, IntrEnable, 1) && 
  590.     NetBfByteTest(statePtr->controlReg, IntrPending, 1))) {
  591.     /*
  592.      * I'm not sure why this is commented out. That's the way I found
  593.      * it.  JHH
  594.      */
  595. #if 0
  596.     if (!polling) {
  597.         printf("Intel: Spurious interrupt <%x>\n", 
  598.         (unsigned int) (*((unsigned char *) statePtr->controlReg)));
  599.     }
  600.     return;
  601. #endif 
  602.     } 
  603.  
  604.     status = NET_IE_CHECK_STATUS(scbPtr->statusWord);
  605.     if (status == 0) {
  606.     if (!polling) {
  607.         printf("Intel: Spurious interrupt (2)\n");
  608.     }
  609.     return;
  610.     }
  611.  
  612.     /*
  613.      * Go ahead and ack the events that got us here.
  614.      */
  615.     NET_IE_CHECK_SCB_CMD_ACCEPT(scbPtr);
  616.     NET_IE_ACK(scbPtr->cmdWord, status);
  617.     NET_IE_CHANNEL_ATTENTION(statePtr);
  618.  
  619.     /*
  620.      * If we got a packet, then process it.
  621.      */
  622.     if (NET_IE_RECEIVED(status)) {
  623.     NetIERecvProcess(FALSE, statePtr);
  624.     }
  625.  
  626.     /*
  627.      * If a transmit command completed then process it.
  628.      */
  629.     if (NET_IE_TRANSMITTED(status)) {
  630.     NetIEXmitDone(statePtr);
  631.     }
  632.     return;
  633. }
  634.  
  635.  
  636.  
  637. /*
  638.  *----------------------------------------------------------------------
  639.  *
  640.  * NetIEGetStats --
  641.  *
  642.  *    Return the statistics for the interface.
  643.  *
  644.  * Results:
  645.  *    A pointer to the statistics structure.
  646.  *
  647.  * Side effects:
  648.  *    None.
  649.  *
  650.  *----------------------------------------------------------------------
  651.  */
  652.  
  653. ReturnStatus
  654. NetIEGetStats(interPtr, statPtr)
  655.     Net_Interface    *interPtr;        /* Current interface. */
  656.     Net_Stats        *statPtr;        /* Statistics to return. */
  657. {
  658.     NetIEState    *statePtr;
  659.     statePtr = (NetIEState *) interPtr->interfaceData;
  660.     DISABLE_INTR();
  661.     statPtr->ether = statePtr->stats;
  662.     ENABLE_INTR();
  663.     return SUCCESS;
  664. }
  665.  
  666. /*
  667.  *----------------------------------------------------------------------
  668.  *
  669.  * NetIEIOControl --
  670.  *
  671.  *    Perform ioctls for the adapter.  Right now we don't support any.
  672.  *
  673.  * Results:
  674.  *    DEV_INVALID_ARG
  675.  *
  676.  * Side effects:
  677.  *    None.
  678.  *
  679.  *----------------------------------------------------------------------
  680.  */
  681.  
  682. /*ARGSUSED*/
  683. ReturnStatus
  684. NetIEIOControl(interPtr, ioctlPtr, replyPtr)
  685.     Net_Interface *interPtr;    /* Interface on which to perform ioctl. */
  686.     Fs_IOCParam *ioctlPtr;    /* Standard I/O Control parameter block */
  687.     Fs_IOReply *replyPtr;    /* Size of outBuffer and returned signal */
  688. {
  689.     return DEV_INVALID_ARG;
  690. }
  691.  
  692. /*
  693.  *----------------------------------------------------------------------
  694.  *
  695.  * NetIEStatePrint --
  696.  *
  697.  *    Prints out the contents of a NetIEState..
  698.  *
  699.  * Results:
  700.  *    None.
  701.  *
  702.  * Side effects:
  703.  *    Stuff is printed.
  704.  *
  705.  *----------------------------------------------------------------------
  706.  */
  707.  
  708. void
  709. NetIEStatePrint(statePtr)
  710.     NetIEState        *statePtr;
  711. {
  712.     printf("statePtr = 0x%x\n", statePtr);
  713.     printf("membase = 0x%x\n", statePtr->memBase);
  714.     printf("sysConfPtr = 0x%x\n", statePtr->sysConfPtr);
  715.     printf("intSysConfPtr = 0x%x\n", statePtr->intSysConfPtr);
  716.     printf("scbPtr = 0x%x\n", statePtr->scbPtr);
  717.     printf("cmdBlockPtr = 0x%x\n", statePtr->cmdBlockPtr);
  718.     printf("recvFrDscHeadPtr = 0x%x\n", statePtr->recvFrDscHeadPtr);
  719.     printf("recvFrDscTailPtr = 0x%x\n", statePtr->recvFrDscTailPtr);
  720.     printf("recvBufDscHeadPtr = 0x%x\n", statePtr->recvBufDscHeadPtr);
  721.     printf("recvBufDscTailPtr = 0x%x\n", statePtr->recvBufDscTailPtr);
  722.     printf("xmitList = 0x%x\n", statePtr->xmitList);
  723.     printf("xmitFreeList = 0x%x\n", statePtr->xmitFreeList);
  724.     printf("xmitCBPtr = 0x%x\n", statePtr->xmitCBPtr);
  725.     printf("transmitting = %d\n", statePtr->transmitting);
  726.     printf("running = %d\n", statePtr->running);
  727.     printf("controlReg = 0x%x\n", statePtr->controlReg);
  728.     printf("netIEXmitTempBuffer = 0x%x\n", statePtr->netIEXmitTempBuffer);
  729.     printf("xmitBufAddr = 0x%x\n", statePtr->xmitBufAddr);
  730.     printf("curScatGathPtr = 0x%x\n", statePtr->curScatGathPtr);
  731.     printf("interPtr = 0x%x\n", statePtr->interPtr);
  732. }
  733.  
  734. /*
  735.  *----------------------------------------------------------------------
  736.  *
  737.  * NetIEIntSysConfPtrPrint --
  738.  *
  739.  *    Prints the contents of a NetIEIntSysConfPtr.
  740.  *
  741.  * Results:
  742.  *    None.
  743.  *
  744.  * Side effects:
  745.  *    Stuff is printed
  746.  *
  747.  *----------------------------------------------------------------------
  748.  */
  749.  
  750. void
  751. NetIEIntSysConfPtrPrint(confPtr) 
  752.     volatile NetIEIntSysConfPtr    *confPtr;
  753. {
  754.     printf("busy = %d\n", (int) confPtr->busy);
  755.     printf("scbOffset = 0x%x\n",  confPtr->scbOffset);
  756.     printf("base = 0x%x\n", confPtr->base); 
  757. }
  758.  
  759. /*
  760.  *----------------------------------------------------------------------
  761.  *
  762.  * NetIESCBPrint --
  763.  *
  764.  *    description.
  765.  *
  766.  * Results:
  767.  *    None.
  768.  *
  769.  * Side effects:
  770.  *    None.
  771.  *
  772.  *----------------------------------------------------------------------
  773.  */
  774.  
  775. void
  776. NetIESCBPrint(scbPtr)
  777.     volatile NetIESCB    *scbPtr;
  778. {
  779.     printf("status = 0x%x\n", * ((unsigned short *) &scbPtr->statusWord));
  780.     printf("cmd = 0x%x\n", * ((unsigned short *) &scbPtr->cmdWord));
  781.     printf("cmdListOffset = 0x%x\n",  scbPtr->cmdListOffset);
  782.     printf("recvFrameAreaOffset = 0x%x\n",  scbPtr->recvFrameAreaOffset);
  783.     printf("crcErrors = %d\n",  scbPtr->crcErrors);
  784.     printf("alignErrors = %d\n",  scbPtr->alignErrors);
  785.     printf("resourceErrors = %d\n",  scbPtr->resourceErrors);
  786.     printf("overrunErrors = %d\n",  scbPtr->overrunErrors);
  787. }
  788.  
  789. /*
  790.  *----------------------------------------------------------------------
  791.  *
  792.  * NetIETransmitCBPrint --
  793.  *
  794.  *    Print the contents of a NetIETransmitCB.
  795.  *
  796.  * Results:
  797.  *    None.
  798.  *
  799.  * Side effects:
  800.  *    stuff is printed.
  801.  *
  802.  *----------------------------------------------------------------------
  803.  */
  804.  
  805. void
  806. NetIETransmitCBPrint(xmitCBPtr)
  807.     NetIETransmitCB    *xmitCBPtr;
  808. {
  809.     char buffer[32];
  810.     printf("xmitCBPtr = 0x%x\n", xmitCBPtr);
  811.     printf("bits = 0x%x\n", xmitCBPtr->bits[0]);
  812.     printf("nextCmdBlock = 0x%x\n", xmitCBPtr->nextCmdBlock);
  813.     printf("bufDescOffset = 0x%x\n", xmitCBPtr->bufDescOffset);
  814.     printf("etherAddress = %s\n", 
  815.     Net_AddrToString((Net_Address *) &xmitCBPtr->destEtherAddr,
  816.     NET_PROTO_RAW, NET_NETWORK_ETHER, buffer));
  817.     printf("type = 0x%x\n", xmitCBPtr->type);
  818. }
  819.  
  820. void
  821. NetIERecvBufDescPrint(recvBufDescPtr)
  822.     NetIERecvBufDesc    *recvBufDescPtr;
  823. {
  824.     printf("recvBufDescPtr = 0x%x\n", recvBufDescPtr);
  825.     printf("bits1 = 0x%x\n", recvBufDescPtr->bits1[0]);
  826.     printf("nextRBD = 0x%x\n", recvBufDescPtr->nextRBD);
  827.     printf("bufAddr = 0x%x\n", recvBufDescPtr->bufAddr);
  828.     printf("bits2 = 0x%x\n", recvBufDescPtr->bits2[0]);
  829.     printf("realBufAddr = 0x%x\n", recvBufDescPtr->realBufAddr);
  830.     printf("realNextRBD = 0x%x\n", recvBufDescPtr->realNextRBD);
  831. }
  832.  
  833. void
  834. NetIERecvFrameDescPrint(recvFrDescPtr) 
  835.     NetIERecvFrameDesc     *recvFrDescPtr;
  836. {
  837.     char    buffer[32];
  838.     printf("NetIERecvFrameDesc = 0x%x\n", recvFrDescPtr);
  839.     printf("bits = 0x%x\n", recvFrDescPtr->bits[0]);
  840.     printf("nextRFD = 0x%x\n", recvFrDescPtr->nextRFD);
  841.     printf("recvBufferDesc = 0x%x\n", recvFrDescPtr->recvBufferDesc);
  842.     printf("destAddr = %s\n", 
  843.     Net_AddrToString((Net_Address *) &recvFrDescPtr->destAddr,
  844.     NET_PROTO_RAW, NET_NETWORK_ETHER, buffer));
  845.     printf("srcAddr = %s\n", 
  846.     Net_AddrToString((Net_Address *) &recvFrDescPtr->srcAddr,
  847.     NET_PROTO_RAW, NET_NETWORK_ETHER, buffer));
  848.     printf("type = 0x%x\n", recvFrDescPtr->type);
  849. }
  850.  
  851. void
  852. NetIETransmitBufDescPrint(xmitBufDescPtr)
  853.     NetIETransmitBufDesc    *xmitBufDescPtr;
  854. {
  855.     printf("xmitBufDescPtr = 0x%x\n", xmitBufDescPtr);
  856.     printf("bits = 0x%x\n", * (unsigned short *) xmitBufDescPtr);
  857.     printf("nextTBD = 0x%x\n", xmitBufDescPtr->nextTBD);
  858.     printf("bufAddr = 0x%x\n", xmitBufDescPtr->bufAddr);
  859. }
  860.  
  861.